/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
/**
* @headerfile daemon.hpp
* 
* Header for easy control of the daemonize process.
*
* @author Miguel Ángel Vílchez López 2008 <sacra@openmatica.es> 
*
* Codigo is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* Codigo is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along
* with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _MOKARDU_DAEMON_HPP_
#define _MOKARDU_DAEMON_HPP_

#include <sys/time.h>
#include <sys/resource.h>
#include "debug.hpp"

/**
* @class CMDaemon
* @brief Daemonizing programs.
*/

class CMDaemon
{

	private:
	
		/**
		* The log class.
		*/
		CMDebug debug;

                /**
                 * The pid id
                */
                int pid;

	public:
	
		/**
		* Constructor.
		*
		* @param[in] priority The priority for the new process, from -19(highest) to 20(lowest).
		* @param[in] debug If the debug is activated.
		* @param[in] filename The file for logging.
		*/
		CMDaemon(const char* filepid,int priority,bool debug,const char* filedebug);
		
		/**
		* Destructor.
		*/
		~CMDaemon();

                /***
                 * Get the pid of the daemon.
                 */
                int getPid();
                
};

#endif // _MOKARDU_DAEMON_HPP_
